//
//  UIImage+CircleImage.m
//  Medicare
//
//  Created by iflytek on 2017/5/23.
//  Copyright © 2017年 medicare. All rights reserved.
//

#import "UIImage+CircleImage.h"

@implementation UIImage (CircleImage)

- (UIImage *)drawCircleImage
{
    return [self drawImageWithRadius:self.size.height * 0.15];
}

- (UIImage *)drawCircleImageRadius:(CGFloat)radius {
    return [self drawImageWithRadius:radius];
}

- (UIImage *)drawImageWithRadius:(CGFloat)radius
{
    UIGraphicsBeginImageContextWithOptions(self.size, NO, self.scale);
    CGRect rect = CGRectMake(0, 0, self.size.width, self.size.height);
    [[UIBezierPath bezierPathWithRoundedRect:rect     cornerRadius:radius] addClip];
    [self drawInRect:rect];
    UIImage* imageNew =     UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return imageNew;
}


@end
